#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@desc: .

@Project ：kuberCloudTest
@File ：test.py
@Author ：admin
@Date ：2024/3/20 9:26 
"""
from api import KuberCloudHttpRequest
from cloud_resources.mirrors import getMountableIso, getMirror
from cloud_resources.networkcard import getNetworkCardByVMId, getAvailableNetworkCardIP
from cloud_resources.recycle_bin import getRecycleVm, getRecycleDisk
from cloud_resources.vms.basic import getThreeLayerNetwork, getNetwork
from cloud_resources.vms.vm_operation import getVms, createVm, getVmDetail
from cloud_resources.volumes.disks import getDataMirror, createDataDiskByImage, createDataDiskBySpec, getDataDiskById, \
    getDataDiskDetail
from infrastructures.clusters import getCluster
from infrastructures.logs import getOperationLog, createOperationLog
from infrastructures.mirror_servers import mirrorServerEnterMaintainMode, getMirrorServer
from infrastructures.physical_machine import getMachine, getMachineDetail
from infrastructures.zone import getZone, changeZone, getMyZone
from kuberCloudTest.cloud_resources.specifications.compute import getComputeSpec
from kuberCloudTest.cloud_resources.specifications.disk import getDiskSpec
from kuberCloudTest.infrastructures.primary_storage import getStorage
from kuberCloudTest.kuberCloud import KuberCloudSDK
from networks.l2network import updateL2Network, getL2network
from networks.privatenetwork import getPrivateNetwork
from networks.publicnetwork import getPublicNetwork
from networks.vpcnetwork import updateVpcNetwork, getMountedVMByVpcNetwork, getVpcNetwork
# from kuberCloudSDK import KuberCloudSDK
from urls import Urls

OFFSET = 0
LIMIT = 20

cloud_sdk = KuberCloudSDK('MGQ5OTAwMTUyZTI1NGVk',
                          'TUdRNU9UQXdNVFV5WlRJMU5HVmtza3l3aW4wOTQ2',
                          '192.168.20.31',
                          '38080')
access_token = cloud_sdk.getAccessToken()
changeZone(access_token, '49c009ae45f546038ca87658bffca11b')
# print(getZone(access_token))
# print(access_token)

# http_request = KuberCloudHttpRequest(accessToken=access_token)
# print(http_request.get(Urls.getZone.value, params={'offset': OFFSET, 'limit': LIMIT}))

# cloud_sdk.refreshAccessToken(access_token)
# print(http_request.get(Urls.getZone.value, params={'offset': OFFSET, 'limit': LIMIT}))
#
# cloud_sdk.removeAccessToken(access_token)
# print(http_request.get(Urls.getZone.value, params={'offset': OFFSET, 'limit': LIMIT}))
# print(getZone(access_token))
# print(getMyZone(access_token))
# changeZone(access_token, '49c009ae45f546038ca87658bffca11b')
# print(getRecycleDisk(access_token))
# print(getVms(access_token))
# print(getCluster(access_token, clusterId='dd74a174c8244db09f40bb15f79bea7c'))
# mirrorServerEnterMaintainMode(access_token, '28f4cb919bc0402480e85f9b1d2ab147')
# print(getMountableIso(access_token, '55fa7173d4e744908b12142f023a96c5'))
# updateL2Network(access_token, '3bc232a6892d4f358d5d74bfe79aa12b', name='100-200-')
# updateVpcNetwork(access_token, '4b0814a59e354cbaa92298c933c37dab', remark='100-200-')
# print(getMountedVMByVpcNetwork(access_token, '4b0814a59e354cbaa92298c933c37dab', shared=False))
# print(getNetworkCardByVMId(access_token, 'aad82d0756814d448616936812406c7f', networkCardId='69567388150a42f795d1e05bb57683fe'))
# print(getAvailableNetworkCardIP(access_token, '170103514a8b477e9320791c3dcfeacf'))
# print(getMachine(access_token))
# print(getOperationLog(access_token, range='2024-04-03 至 2024-04-11', success=0))
# print(createOperationLog(access_token, range='2024-04-03 至 2024-04-11', success=0))

# createDataDiskByImage(access_token, 'dkfklsdjl', 'b6d918d3b230463787f401bc71e06c7d',
#                       '624c25db1b7d4fa2a7f777650c1b9c2b', 'd8ce6df2880d4ea4ab1479bae25dc88a')


# createDataDiskBySpec(access_token, 'ha11haha',
#                      '59040dd86337449d9febb4be71b16098',
#                      'b6d918d3b230463787f401bc71e06c7d',
#                      'a7d622ec1a1048f783dd5e0ec5ef3c47', vmid='', number=2)

# print(getDataDiskDetail(access_token, '6809a037d0584bc69c6b6029b338f8c3'))

# print(getThreeLayerNetwork(access_token, networkids='93d57bef8da740c69666082fb36f568a,e6de8e56f8a040bb8627dcb1f9e48e50,14a3c47ec1e34aac855d3e8da09949bf'))

# createVm(access_token, basicConf, computeResourceConf, storageResourceConf, networkResourceConf)
# print(getL2network(access_token, l2NetworkId='c8c713afd3654f79a1518f9a6538dd15', limit=2))
# print(getVmDetail(access_token, vmid='c8c713afd3654f79a1518f9a6538dd15'))
# print(getMirror(access_token, mirrorId='22e0a8310e754c84814fbfdfd9ae409f'))
print(getComputeSpec(access_token, specId='f8c454a6d9cd4594b937712f4eda3ad5', limit=2))
# print(getMachineDetail(access_token, 'a7d622ec1a1048f783dd5e0ec5ef3c47'))